0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 178 ms)
↳10 BOUNDS(1, n^2)
cond(true, x) → cond(odd(x), p(x))
odd(0) → false
odd(s(0)) → true
odd(s(s(x))) → odd(x)
p(0) → 0
p(s(x)) → x
cond(true, x) → cond(odd(x), p(x)) [1]
odd(0) → false [1]
odd(s(0)) → true [1]
odd(s(s(x))) → odd(x) [1]
p(0) → 0 [1]
p(s(x)) → x [1]
cond(true, x) → cond(odd(x), p(x)) [1]
odd(0) → false [1]
odd(s(0)) → true [1]
odd(s(s(x))) → odd(x) [1]
p(0) → 0 [1]
p(s(x)) → x [1]
cond :: true:false → 0:s → cond true :: true:false odd :: 0:s → true:false p :: 0:s → 0:s 0 :: 0:s false :: true:false s :: 0:s → 0:s |
cond(v0, v1) → null_cond [0]
null_cond
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
true => 1
0 => 0
false => 0
null_cond => 0
cond(z, z') -{ 1 }→ cond(odd(x), p(x)) :|: z' = x, z = 1, x >= 0
cond(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
odd(z) -{ 1 }→ odd(x) :|: x >= 0, z = 1 + (1 + x)
odd(z) -{ 1 }→ 1 :|: z = 1 + 0
odd(z) -{ 1 }→ 0 :|: z = 0
p(z) -{ 1 }→ x :|: x >= 0, z = 1 + x
p(z) -{ 1 }→ 0 :|: z = 0
eq(start(V, V1),0,[cond(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1),0,[odd(V, Out)],[V >= 0]). eq(start(V, V1),0,[p(V, Out)],[V >= 0]). eq(cond(V, V1, Out),1,[odd(V2, Ret0),p(V2, Ret1),cond(Ret0, Ret1, Ret)],[Out = Ret,V1 = V2,V = 1,V2 >= 0]). eq(odd(V, Out),1,[],[Out = 0,V = 0]). eq(odd(V, Out),1,[],[Out = 1,V = 1]). eq(odd(V, Out),1,[odd(V3, Ret2)],[Out = Ret2,V3 >= 0,V = 2 + V3]). eq(p(V, Out),1,[],[Out = 0,V = 0]). eq(p(V, Out),1,[],[Out = V4,V4 >= 0,V = 1 + V4]). eq(cond(V, V1, Out),0,[],[Out = 0,V5 >= 0,V6 >= 0,V = V5,V1 = V6]). input_output_vars(cond(V,V1,Out),[V,V1],[Out]). input_output_vars(odd(V,Out),[V],[Out]). input_output_vars(p(V,Out),[V],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [odd/2]
1. non_recursive : [p/2]
2. recursive : [cond/3]
3. non_recursive : [start/2]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into odd/2
1. SCC is partially evaluated into p/2
2. SCC is partially evaluated into cond/3
3. SCC is partially evaluated into start/2
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations odd/2
* CE 9 is refined into CE [12]
* CE 8 is refined into CE [13]
* CE 7 is refined into CE [14]
### Cost equations --> "Loop" of odd/2
* CEs [13] --> Loop 9
* CEs [14] --> Loop 10
* CEs [12] --> Loop 11
### Ranking functions of CR odd(V,Out)
* RF of phase [11]: [V-1]
#### Partial ranking functions of CR odd(V,Out)
* Partial RF of phase [11]:
- RF of loop [11:1]:
V-1
### Specialization of cost equations p/2
* CE 11 is refined into CE [15]
* CE 10 is refined into CE [16]
### Cost equations --> "Loop" of p/2
* CEs [15] --> Loop 12
* CEs [16] --> Loop 13
### Ranking functions of CR p(V,Out)
#### Partial ranking functions of CR p(V,Out)
### Specialization of cost equations cond/3
* CE 6 is refined into CE [17]
* CE 5 is refined into CE [18,19,20,21]
### Cost equations --> "Loop" of cond/3
* CEs [21] --> Loop 14
* CEs [20] --> Loop 15
* CEs [19] --> Loop 16
* CEs [18] --> Loop 17
* CEs [17] --> Loop 18
### Ranking functions of CR cond(V,V1,Out)
* RF of phase [14]: [V1-2]
#### Partial ranking functions of CR cond(V,V1,Out)
* Partial RF of phase [14]:
- RF of loop [14:1]:
V1-2
### Specialization of cost equations start/2
* CE 2 is refined into CE [22,23,24]
* CE 3 is refined into CE [25,26,27,28]
* CE 4 is refined into CE [29,30]
### Cost equations --> "Loop" of start/2
* CEs [22] --> Loop 19
* CEs [23,24,26,27,28,30] --> Loop 20
* CEs [25,29] --> Loop 21
### Ranking functions of CR start(V,V1)
#### Partial ranking functions of CR start(V,V1)
Computing Bounds
=====================================
#### Cost of chains of odd(V,Out):
* Chain [[11],10]: 1*it(11)+1
Such that:it(11) =< V
with precondition: [Out=0,V>=2]
* Chain [[11],9]: 1*it(11)+1
Such that:it(11) =< V
with precondition: [Out=1,V>=3]
* Chain [10]: 1
with precondition: [V=0,Out=0]
* Chain [9]: 1
with precondition: [V=1,Out=1]
#### Cost of chains of p(V,Out):
* Chain [13]: 1
with precondition: [V=0,Out=0]
* Chain [12]: 1
with precondition: [V=Out+1,V>=1]
#### Cost of chains of cond(V,V1,Out):
* Chain [[14],18]: 3*it(14)+1*s(3)+0
Such that:aux(3) =< V1
it(14) =< aux(3)
s(3) =< it(14)*aux(3)
with precondition: [V=1,Out=0,V1>=3]
* Chain [[14],15,18]: 4*it(14)+1*s(3)+3
Such that:aux(4) =< V1
it(14) =< aux(4)
s(3) =< it(14)*aux(4)
with precondition: [V=1,Out=0,V1>=3]
* Chain [18]: 0
with precondition: [Out=0,V>=0,V1>=0]
* Chain [17,18]: 3
with precondition: [V=1,V1=0,Out=0]
* Chain [16,18]: 3
with precondition: [V=1,V1=1,Out=0]
* Chain [16,17,18]: 6
with precondition: [V=1,V1=1,Out=0]
* Chain [15,18]: 1*s(4)+3
Such that:s(4) =< V1
with precondition: [V=1,Out=0,V1>=2]
#### Cost of chains of start(V,V1):
* Chain [21]: 1
with precondition: [V=0]
* Chain [20]: 8*s(13)+2*s(14)+2*s(15)+6
Such that:s(12) =< V1
aux(6) =< V
s(15) =< aux(6)
s(13) =< s(12)
s(14) =< s(13)*s(12)
with precondition: [V>=1]
* Chain [19]: 3
with precondition: [V>=0,V1>=0]
Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [21] with precondition: [V=0]
- Upper bound: 1
- Complexity: constant
* Chain [20] with precondition: [V>=1]
- Upper bound: 2*V+6+nat(V1)*8+nat(V1)*2*nat(V1)
- Complexity: n^2
* Chain [19] with precondition: [V>=0,V1>=0]
- Upper bound: 3
- Complexity: constant
### Maximum cost of start(V,V1): max([2,2*V+5+nat(V1)*8+nat(V1)*2*nat(V1)])+1
Asymptotic class: n^2
* Total analysis performed in 157 ms.